<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.LinkedHashMap" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.io.PrintWriter" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<%@ page language="java" contentType="text/html; charset=UTF-8" %>

<%
    String sql = "select CONVERT(varchar(100), GETDATE(), 23) as nowDate";
    rs.executeSql(sql);
    rs.next();
    String d = rs.getString("nowDate");
    //获取当前日期
    //Date d = new Date();
//    String format = "%1$tY-%1$tm-%1$td";
//    sql = "select CONVERT(varchar(100), GETDATE(), 23) as nowDate,datepart(weekday, getdate())-1 as nowWeekday,zb,isyb from formtable_main_3 where qsrq <='"+String.format(format, d)+"' and jsrq>='"+String.format(format, d)+"'";
    sql = "select CONVERT(varchar(100), GETDATE(), 23) as nowDate,datepart(weekday, getdate())-1 as nowWeekday,zb,isyb from formtable_main_3 where qsrq <='"+d+"' and jsrq>='"+d+"'";
    rs.executeSql(sql);
    if(rs.next()){
        String zhoubie = Util.null2String(rs.getString("zb"));//周别
        String isyb = Util.null2String(rs.getString("isyb"));//是否特定周别
        String nowDate = Util.null2String(rs.getString("nowDate"));//当前服务器时间
        String nowWeekday = Util.null2String(rs.getString("nowWeekday"));//当前周
        Map<String,String> map = new LinkedHashMap<String,String>();
        map.put("zhoubie",zhoubie);
        map.put("isyb","1".equals(isyb)?"true":"false");
        map.put("nowDate",nowDate);
        map.put("isZ1Z2Z3",("1".equals(nowWeekday)||"2".equals(nowWeekday)||"3".equals(nowWeekday))?"true":"false");

        //转换json
        net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(map);
        PrintWriter writer = response.getWriter();
        writer.write(jsonObject.toString());
    }

%>